<?php include "functionsession.php";?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script language="javascript">
    $(function(){
        //导航切换
        $(".imglist li").click(function(){
            $(".imglist li.selected").removeClass("selected")
		$(this).addClass("selected");
	})
})
</script>
<script type="text/javascript">
    $(document).ready(function(){
        $(".click").click(function(){
            $(".tip").fadeIn(200);
        });

        $(".tiptop a").click(function(){
            $(".tip").fadeOut(200);
        });

        $(".sure").click(function(){
            $(".tip").fadeOut(100);
        });

        $(".cancel").click(function(){
            $(".tip").fadeOut(100);
        });

    });
</script>
</head>


<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">图片列表</a></li>
    </ul>
    </div>

    <div class="rightinfo">



    <table class="imgtable">

    <thead>
    <tr>
        <th>Id</th>
    <th width="100px;">缩略图</th>
    <th>标题</th>

    <th>发布日期</th>
    <th>修改</th>
    <th>删除</th>
    </tr>
    </thead>

    <tbody>

<?php
//数据库连接
$conn=mysqli_connect("localhost","root","root","com");
if (!$conn)
{
    die("连接错误: " . mysqli_connect_error());
}else{

    //获取总页数
    $sql_tt = "select pro_id,pro_title,pro_imgsrc1,pro_adddate from pro";
    $result_t = $conn->query($sql_tt);
    $countsize=$result_t->num_rows;//数据库总条数
//    echo "总条数:".$countsize."<hr>";


//    limit 8,2 从第几条数据开始 ，  一共显示多少条数据
    $pagesize=5;//配置每页显示多少条记录
    $countpage=ceil($countsize/$pagesize);//总页数
//    echo "总页数:".."<hr>";

    $page=$_GET["pages"];//当前显示页数
    $pro_index=0;//当前起始数据

    if($page>1)
    {
        $pro_index=($page-1)*$pagesize;
    }


    $sql = "select pro_id,pro_title,pro_imgsrc1,pro_adddate from pro limit $pro_index,".$pagesize."";
    $result = $conn->query($sql);
    if ($result->num_rows > 0)
    {
        while ($row = $result->fetch_assoc())
        {
?>
            <tr>
                <td><?php echo $row["pro_id"]?></td>
                <td class="imgtd"><img src="/web/<?php echo $row["pro_imgsrc1"]?>" /></td>
                <td><?php echo $row["pro_title"]?></td>
                <td><?php echo $row["pro_adddate"]?></td>
                <td>修改 </td>
                <td><a href="delete_pro.php?pid=<?php echo $row["pro_id"]?>&pages=<?php echo $page;?>"> 删除</a></td>

            </tr>
<?php
        }
    }
}
?>





    </tbody>

    </table>
<style type="text/css">
    #new_a{
        width: 80px;
        margin-left: 10px;
    }
</style>


    <div class="pagin">
    	<div class="message">共<i class="blue"><?php echo $countsize;?></i>条记录，当前显示第&nbsp;<i class="blue"><?php echo $page;?>&nbsp;</i>页</div>
        <ul class="paginList">
            <li class="paginItem"><a href="select_pro_1.php?pages=1" id="new_a">首页</a></li>
<!--上一页-->
            <?php if($page>1){
                ?>
            <li class="paginItem"><a href="select_pro_1.php?pages=<?php echo $page-1;?>" id="new_a">上一页</a></li>
            <?php
                  }else {
             ?>
                 <li class="paginItem"><a href="" id="new_a">上一页</a></li>
            <?php
            }
            ?>
<!--下一页-->
            <?php if($page>=$countpage){
                ?>
                <li class="paginItem"><a href="" id="new_a">下一页</a></li>

                <?php
            }else {
                ?>
                <li class="paginItem"><a href="select_pro_1.php?pages=<?php echo $pages+1;?>" id="new_a">下一页</a></li>
                <?php
            }
            ?>

            <li class="paginItem"><a href="select_pro_1.php?pages=<?php echo $countpage;?>"  id="new_a">未页</a></li>
        </ul>
    </div>


    <div class="tip">
    	<div class="tiptop"><span>提示信息</span><a></a></div>

      <div class="tipinfo">
        <span><img src="images/ticon.png" /></span>
        <div class="tipright">
        <p>是否确认对信息的修改 ？</p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
        </div>
        </div>

        <div class="tipbtn">
        <input name="" type="button"  class="sure" value="确定" />&nbsp;
        <input name="" type="button"  class="cancel" value="取消" />
        </div>

    </div>




    </div>

    <div class="tip">
    	<div class="tiptop"><span>提示信息</span><a></a></div>

      <div class="tipinfo">
        <span><img src="images/ticon.png" /></span>
        <div class="tipright">
        <p>是否确认对信息的修改 ？</p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
        </div>
        </div>

        <div class="tipbtn">
        <input name="" type="button"  class="sure" value="确定" />&nbsp;
        <input name="" type="button"  class="cancel" value="取消" />
        </div>

    </div>

<script type="text/javascript">
    $('.imgtable tbody tr:odd').addClass('odd');
	</script>
</body>
</html>